Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

386
Visualizações
Bootstrap event "shown.bs.modal" fires multiple times everytime I click the toggle button

I am building a pdf view with PDF.js to render pdf inside bootstrap modal, and according to the documentation I can listen to "shown.bs.modal" event when the modal popup is displayed so I have this code:

function renderPdfMobile() {
  docs.forEach(doc => {
    doc.addEventListener("click", function (e) {
      const file = e.target.dataset.file;

      var modal = document.getElementById("fileModal");
      modal.addEventListener('shown.bs.modal', function (event) {

      

      console.log(modal)

      })

    })

  })
}

renderPdfMobile()

Code works every time I click the modal button. The problem is it fires with the increment of +1 every time.

So in console When I click once, I get "fired" when I click again I get

"fired"
"fired"

another click results in:

"fired"
"fired"
"fired"

At this point, I don't know what I am doing wrong.

EDITED

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda